<template>
  <div class="contract-class">
    <div>
      <UE :config="config" :elList='elList' v-model="content" ref="ue"></UE>
    </div>
     <!--<el-button @click="getElList">模板元素</el-button>-->
  </div>
</template>

<script>
  import UE from '../ue/ue';
  export default {
    props: ['templateContent','elList'],
    data() {
      return {
        content:'',
        config: {
          initialFrameHeight:'100%',
          initialFrameWidth:'100%',
          scaleEnabled: true,
          enableAutoSave: false,
          zIndex:9999,
          toolbars:[[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help','|',
             'inputcode','selection', 'inputdate', 'tablecode','labelcode', 'selecturl'
          ]]
        }
      };
    },
    components:{
      UE
    },
    created(){
    },
    mounted(){
       this.content = this.templateContent;
    },
    methods: {
      getElList(){
        let elList = this.$refs.ue.getElList();
        for (let i = elList.length - 1; i >= 0; i--) {
          if (this.content.indexOf(elList[i].elId) < 0) {
            elList.splice(i, 1);
          }
        }
        return elList;
        // this.$router.push({ name: 'contractShow', params: { content: this.content, elList: this.$refs.ue.getElList()}});
      },
      getTemplate(){
        return {
          templateContent: this.content,
          elementList: this.getElList()
        }
      }

    },
    computed: {

    },
    watch: {
      templateContent(val){
        this.content = val;
      }
    }
  }
</script>

<style scoped>
  .contract-class{
  }

  .contract-class>div{
  }

  .contract-class .toolbar{
    height: 102px;
    position: fixed;
    top: 0;
    left: 50%;
    right: 0;
    border-bottom: 1px solid #d1dbe5;
    background-color: #fff;
  }
  .contract-class .content-show{
    margin-top: 102px;
    padding: 6px;
  }

</style>
